<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

$router->get('/', function () use ($router) {

    return $router->app->version();
});
//登录
$router->post('adminlogin', 'Account\AdminController@login');

//测试员工认证路由   加登录中间件
$router->group(['middleware' => 'admin'], function () use ($router) {
    $router->get('/admin', 'Account\AdminController@admin');
});

//上传图片  文件
$router->post('photo', 'UploadImgController@UploadPic');
//多图上传带水印
$router->post('uploadimg','UploadImgController@UploadFiles');


/**
 * 定时任务
 */
$router->group(['namespace' => 'Task', 'prefix' => 'task'], function () use ($router) {

    $router->group(['prefix' => 'account', 'middleware' => 'task.token'], function () use ($router) {

        $router->get('updateaccount', 'ExpiredAccountController@updateAccount');

        //公司房客更新规则状态更新
        $router->get('updatestatus', 'UpdateMoveRuleController@updateStatus');

    });

});


//平台内部用户
$router->group(['middleware' => 'admin','namespace' => 'Account', 'prefix' => 'account'], function () use ($router) {

    //用户列表
    $router->get('adminlist', 'AdminController@adminList');

    //添加用户
    $router->post('adminadd', 'AdminController@adminAdd');

    //修改用户
    $router->post('adminedit', 'AdminController@adminEdit');

    //禁用用户
    $router->post('updatestatus', 'AdminController@updateStatus');

    //修改密码
    $router->post('updatepass', 'AdminController@updatePass');

});


//平台创建账号给中介公司
$router->group(['middleware' => 'admin','namespace' => 'Account', 'prefix' => 'account'], function () use ($router) {

    //中介公司管理账号列表
    $router->get('list', 'AdministrationController@listAdmin');

    //添加中介公司管理账号
    $router->post('add', 'AdministrationController@addAdmin');//添加成功以后该账号还是不能直接使用的  需要把一系列表创建完成 并审核通过以后才能正常使用

    //创建客源表
    $router->get('createcustomers', 'CreateTableController@createCustomers');

    //审核中介公司账号
    $router->get('examineaccount', 'AdministrationController@examineAccount');

    //修改中介公司账号的状态（审核   禁用启用）
    $router->get('updatecompanystatus', 'AdministrationController@updateCompanyStatus');

    //中介公司缴费记录列表
    $router->get('getpaylist', 'AdministrationController@getPayList');

    //提交中介公司的续费  等待审核
    $router->post('pay', 'AdministrationController@pay');

    //审核中介公司的续费
    $router->get('examinerenew', 'AdministrationController@examineRenew');

    //账号等级列表
    $router->get('memberlist', 'AdministrationController@memberList');
    
    //分类列表
    $router->get('typelist', 'TypeController@typeList');

    //添加分类
    $router->post('typeadd', 'TypeController@typeAdd');

    //修改分类
    $router->post('typeedit', 'TypeController@typeEdit');

    //删除分类
    $router->post('typedel', 'TypeController@typeDel');

    //获取所有分类
    $router->get('getalltype', 'TypeController@getAllType');

    //分类状态列表
    $router->get('typedetaillist', 'TypeDetailController@typeDetailList');

    //添加分类状态
    $router->post('typedetailadd', 'TypeDetailController@typeDetailAdd');

    //修改分类状态
    $router->post('typedetailedit', 'TypeDetailController@typeDetailEdit');

    //删除分类状态
    $router->post('typedetaildel', 'TypeDetailController@typeDetailDel');

});

/**
 * 系统配置的房客源 下所有的分类
 */
$router->group(['middleware' => 'admin','namespace' => 'Account', 'prefix' => 'system'], function () use ($router) {

    //列表
    $router->get('list', 'SystemTypeController@listType');

    //添加
    $router->post('add', 'SystemTypeController@addType');

    //修改
    $router->post('edit', 'SystemTypeController@editType');

    //删除
    $router->get('del', 'SystemTypeController@delType');

});


//测试用户认证路由   加登录中间件
$router->group(['middleware' => 'auth'], function () use ($router) {
    $router->get('/auth', 'Backstage\UserController@user');
});

$router->post('login', 'Backstage\LoginController@index');

//三级联动
$router->get('area', 'Backstage\AreaController@listArea');

$router->get('city', 'Backstage\AreaController@getCity');
/**
 * 客源管理
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'customers'], function () use ($router) {

    //列表
    $router->get('list', 'CustomersController@listCustomers');

    //获取跟进内容
    $router->get('follow','CustomersController@customerFollow');

    //客源智能匹配推荐房源
    $router->post('recommend','CustomersController@customersRecommendRoom');

    //添加修改 客源录入手机号时验证手机号是否存在
    $router->get('repeat', 'CustomersController@repeatAddition');

    //添加客源信息
    $router->post('add', 'CustomersController@addCustomers');

    //修改客源信息
    $router->post('update', 'CustomersController@updatecustomers');

    //客源信息放到回收站
    $router->post('recyclebin', 'CustomersController@recycleBin');

    //删除客源信息
    $router->post('del', 'CustomersController@del');

    //回收站的客源信息列表
    $router->get('recyclebininfo', 'CustomersController@recycleBinInfo');

    //用户添加客源跟进
    $router->post('addfollow', 'CustomerFollowController@addCustomerFollow');

    //删除客源跟进
    $router->post('delfollow','CustomerFollowController@delCustomerFollow');

    //用户修改客源状态和分配业绩  《此接口只有在对接的时候进行调整暂时不做调整》
    $router->post('addCustomersAchievement','CustomersController@addAchievement');

    //获取房源  客源里面所有能用到的类型种类
    $router->get('getalltypedetail', 'CustomersController@getAllTypeDetail');
});


/**
 * 房源管理
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'room'], function () use ($router) {

    //房源列表
    $router->get('list', 'RoomInfoController@houseList');

    //打开新增房源的页面  获取的类型值
    $router->get('getdefaulttype','RoomInfoController@getDefaultType');

    //增加房源
    $router->post('inserthouse','RoomInfoController@insertHouse');

    //修改房源
    $router->post('updatahouse','RoomInfoController@updataHouse');

    //删除房源到回收站
    $router->post('softdel','RoomInfoController@softDelHouse');

    //删除房源
    $router->post('delhouse','RoomInfoController@DelHouse');

    //用户添加房源跟进
    $router->post('roomfollow','RoomFollowController@addRoomFollow');

    //用户修改房源状态和分配业绩
    $router->post('addAchievement','RoomInfoController@addAchievement');

    //房源详情、编辑
    $router->get('infohouse','RoomInfoController@infoHouse');

    //交易合同    诚意金  等快速查找房源列表接口
    $router->get('fastlist', 'RoomInfoController@houseListFast');

});




/**
 * 楼盘字典管理
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'wordbook'], function () use ($router) {

    //楼盘字典添加页下拉框数据
    $router->get('datawordbook','RoomWordbookController@wordType');

    //添加楼盘字典
    $router->post('addwordbook','RoomWordbookController@insertBook');

    //删除楼盘字典
    $router->get('delwordbook','RoomWordbookController@delBook');

    //修改楼盘字典
    $router->post('savewordbook','RoomWordbookController@saveBook');

    //查询楼盘字典
    $router->get('listwordbook','RoomWordbookController@listBook');

    //栋座添加时下拉框类型数据
    $router->get('wordbooktype','RoomWordbookController@wordBookType');

    //添加楼盘字典 - 栋座信息
    $router->post('addbuilding','RoomWordbookController@addBuilding');

    //批量添加楼盘字典 -栋座信息
    $router->post('batchaddbuilding','RoomWordbookController@batchAddBuilding');

    //修改楼盘字典 - 栋座信息
    $router->post('savebuilding','RoomWordbookController@saveBuilding');

    //删除楼盘字典 - 栋座信息  逻辑删除
    $router->get('delbuilding','RoomWordbookController@delBuilding');

    //查询楼盘字典 - 栋座信息
    $router->get('listbuilding','RoomWordbookController@listBuilding');

    //添加房源时搜索楼盘字典
    $router->get('searchwordbook','RoomWordbookController@searchBook');

    //添加房源是根据楼盘字典获取该楼盘下面的栋座
    $router->get('getbuilding','RoomWordbookController@getBuilding');

    //添加房源时根据栋座的名称获取该栋座下的所有位置信息
    $router->get('getposition','RoomWordbookController@getPosition');

    //获取楼盘字典详细信息
    $router->get('infowordbook','RoomWordbookController@infoBook');
});


/**
 * 部门管理
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'department'], function () use ($router) {

    //获取部门信息列表
    $router->get('list', 'DepartmentController@getDepartmentList');

    //添加部门信息
    $router->post('add', 'DepartmentController@addDepartment');

    //修改部门信息
    $router->post('edit', 'DepartmentController@editDepartment');

    //删除部门信息
    $router->post('del', 'DepartmentController@delDepartment');

    /**
     *公用检索条件下拉框    部门的下拉框
     */
    $router->get('dropdown', 'DepartmentController@dropdown');//部门的下拉框
    $router->get('userdropdown', 'DepartmentController@userDropdown');//员工的下拉框

});
/**
 * 用户管理
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'user'], function () use ($router) {

    //获取用户信息列表
    $router->get('list', 'UserController@getUserList');

    //添加用户信息
    $router->post('add', 'UserController@addUser');

    //修改用户信息
    $router->post('save', 'UserController@saveUser');

    //删除用户信息
    $router->post('del', 'UserController@delUser');

    //上级领导重置员工的密码
    $router->get('resetpassword', 'UserController@resetPassword');

    //员工自己修改自己的密码
    $router->post('updatepassword', 'UserController@updatePassword');

});
/**
 * 用户打卡签到d
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'signin'], function () use ($router) {

    //上班打卡
    $router->post('gotowork', 'SigninController@goToWork');

    //下班打卡
    $router->post('afterwork', 'SigninController@afterWork');

    //签到详情列表
    $router->get('rankings', 'SigninController@Rankings');

    //经理点评
    $router->post('sigincomment', 'SigninController@siginComment');
});

/**
 * 模块及权限
 */
$router->group(['prefix' => 'core', 'namespace' => 'Core'], function () use ($router){
//  模块增删改查
    $router->post('module/add', 'ModuleController@addModule');
    $router->post('module/delete', 'ModuleController@deleteModule');
    $router->post('module/edit', 'ModuleController@editModule');
    $router->get('module/one', 'ModuleController@oneModule');
    $router->get('module/list', 'ModuleController@getModuleList');

//  权限增删改查
    $router->post('authority/add', 'AuthorityController@addAuthority');
    $router->post('authority/delete', 'AuthorityController@deleteAuthority');
    $router->post('authority/edit', 'AuthorityController@editAuthority');
    $router->get('authority/one', 'AuthorityController@oneAuthority');
    $router->get('authority/list', 'AuthorityController@getAuthorityList');
    $router->get('authority/allofmodule', 'AuthorityController@getAuthoritiesAllOfModule'); // [ {module:'', authorities:[{...},{...} ...] } ]

//  给用户授权
    $router->get('authority/edituser', 'AuthorityUsageController@saveUserAuthority');

//  给职务授权
    $router->get('authority/editduty', 'AuthorityUsageController@saveDutyAuthority');
});

/**
 * 数据统计
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'statistics'], function () use ($router) {
    //业绩排行
    $router->get('achievementList', 'AchievementController@getAchievementList');
    //员工房源排行
    $router->get('roomachievementList', 'AchievementController@getRoomInfoAchievementList');
    //员工客源排行
    $router->get('customerachievementList', 'AchievementController@getCustomerInfoAchievementList');
    //员工房源跟进排行
    $router->get('roomfollownum', 'AchievementController@getRoomFollowNum');
    //员工客源跟进排行
    $router->get('customersfollownum', 'AchievementController@getCustomersFollowNum');
});
/**
 * 合同模块
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'contract'], function () use ($router) {

    // 合同列表
    $router->get('list', 'ContractController@lists');

    //添加合同
    $router->post('add', 'ContractController@add');

    //修改合同
    $router->post('edit', 'ContractController@edit');

    //删除合同
    $router->post('delete', 'ContractController@delete');

});

/**
 * 诚意金模块
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'earnest'], function () use ($router) {

    //添加诚意金下拉框动态数据
    $router->get('datalist', 'ContractEarnestMoneyController@dataList');

    // 诚意金列表
    $router->get('list', 'ContractEarnestMoneyController@listEarnest');

    //添加诚意金
    $router->post('add', 'ContractEarnestMoneyController@addEarnest');

    //修改诚意金
    $router->post('edit', 'ContractEarnestMoneyController@editEarnest');

    //删除诚意金
    $router->get('delete', 'ContractEarnestMoneyController@delEarnest');

});




/**
 * 工作总结
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'work'], function () use ($router) {

    //工作总结列表
    $router->get('list', 'WorkSummaryController@workList');

    //点击新增工作总结的页面
    $router->get('page', 'WorkSummaryController@workAddPage');

    //添加工作总结
    $router->post('add', 'WorkSummaryController@workAdd');

    //修改工作总结
    $router->post('edit', 'WorkSummaryController@editAdd');

    //删除工作总结到回收站 从回收站还原工作总结的信息
    $router->get('soft', 'WorkSummaryController@softDel');

    //从回收站删除工作总结《彻底删除》
    $router->get('hard', 'WorkSummaryController@hardDel');

    //经理点评
    $router->post('managerreview', 'WorkSummaryController@managerReview');

    //回收站工作总结的列表
    $router->get('recyclebinlist', 'WorkSummaryController@recycleBinList');
});
/**
 * 公司房客自动转移规则模块
 */
$router->group(['middleware' => 'auth','namespace' => 'Backstage', 'prefix' => 'moverule'], function () use ($router) {

    //添加自动转移规则下拉框动态数据
    $router->get('datalist', 'MoveRuleController@dataList');

    // 自动转移规则列表
    $router->get('list', 'MoveRuleController@lists');

    //添加自动转移规则
    $router->post('add', 'MoveRuleController@addRule');

    //修改自动转移规则
    $router->post('edit', 'MoveRuleController@editRule');

    //删除自动转移规则
    $router->post('delete', 'MoveRuleController@delRule');

    //手动执行规则
    $router->get('save', 'MoveRuleController@immediateSave');

    //员工转房客
    $router->post('moves', 'MoveRuleController@moves');

    //转出类目数据列表
    $router->get('movedata', 'MoveRuleController@moveData');

    //员工公私盘 公私客相互转换页面下拉数据
    $router->get('turndata', 'MoveRuleController@turnData');

    //员工公私盘 公私客相互转换
    $router->post('turns', 'MoveRuleController@turns');
});



//获取Redis里面的下拉框
$router->group(['middleware'=>'auth','prefix' => 'systemtype', 'namespace' => 'Account'], function () use ($router) {

    $router->get('getdropdownbox', 'SystemTypeController@getDropDownBox');
});




//移动端房源信息
$router->group(['middleware'=>'auth','namespace'=>'Mobile\Room','prefix'=>'mobile'],function () use ($router){
    //房源列表
    $router->post('roomlist', 'RoomController@AppRoomList');

    //添加房源
    $router->post('addroom','RoomController@addroom');

});
//移动端客源信息
$router->group(['middleware'=>'auth','namespace'=>'Mobile\Customer','prefix'=>'mobile'],function () use ($router){
    //客源列表
    $router->post('customerslist', 'CustomersController@CustomerList');

    //添加计划任务（仅限标记自己的客源）
    $router->post('addtask','CustomersController@addtask');
    //个人信息
    $router->post('personalinfo','CustomersController@personalInfo');
    //添加客源
    $router->post('addcustomers', 'CustomersController@addcustomers');
});
//移动端计划任务
$router->group(['middleware'=>'auth','namespace'=>'Mobile','prefix'=>'mobile'],function () use ($router){
    //计划任务列表
    $router->post('plantasklist', 'PlanTaskController@plantasklist');
    //修改计划任务
    $router->post('updateplantask', 'PlanTaskController@updateplantask');
    //删除计划任务
    $router->post('delplantask', 'PlanTaskController@delplantask');

});
//Help
$router->group(['namespace'=>'Help','prefix'=>'help'],function () use ($router){
    //公司介绍
    $router->get('companyinfo','HelpController@companyInfo');
    //使用说明
    $router->get('usehelp','HelpController@useHelp');
    //联系我们
    $router->get('contactus','HelpController@contactUs');

});